#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by Gu Xi on 2018/12/11
from selenium import webdriver
from newshead.conf import driver_path, MONGO_DB_NAME, MONGO_URL
from newshead.utils import MongoHelper

chrome_options = webdriver.ChromeOptions()
# chrome_options.add_argument('--headless')    # 静默模式
chrome_options.add_argument('--disable-gpu')  # 忽略警告提示语
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_path['chrome_office'])

driver.get("https://www.baidu.com")

elements = driver.find_element_by_class_name()


def get_news(source):
    """
    :param source: News source
    :return:
    """
    data = None
    return data


def flush_to_mongo(mongo_url: str, mongo_db_name: str, data: dict):
    with MongoHelper(mongo_url, mongo_db_name) as m:
        m.insert_many(data)

    return


def run():
    news_data = get_news()
    flush_to_mongo(MONGO_URL, MONGO_DB_NAME, news_data)